home *** CD-ROM | disk | FTP | other *** search
/ Solar System Explorer / Solar System Explorer.iso / Start.exe / Start.dcr / Internal_158_Fade to picture, fade away.ls < prev    next >
Encoding:
Text File  |  2010-08-18  |  3.1 KB  |  78 lines

  1. property pFadeLength, pPictureLength, pPicture, pStartTime, pElapsedTime, pCurrentOpacity, pOverlayNumber, pTextureName
  2.  
  3. on beginSprite me
  4.   pFadeLength = pFadeLength * 1000
  5.   pPictureLength = pPictureLength * 1000
  6.   theMember = member("3d")
  7.   pTextureName = "slideshowTexture-" & pPicture.name
  8.   theTexture = theMember.newTexture(pTextureName)
  9.   theTexture.member = pPicture
  10.   theCamera = theMember.camera("DefaultView")
  11.   theOverlayCount = theCamera.overlay.count
  12.   theCamera.addOverlay(theTexture, point(320, 223), 0)
  13.   pOverlayNumber = theOverlayCount + 1
  14.   theCamera.overlay[pOverlayNumber].blend = 0
  15.   theCamera.overlay[pOverlayNumber].scale = 0.0007
  16.   pStartTime = the milliSeconds
  17. end
  18.  
  19. on exitFrame me
  20.   pElapsedTime = the milliSeconds - pStartTime
  21.   put "pElapsedTime = " & pElapsedTime & ", pFadeLength = " & pFadeLength
  22.   if pElapsedTime < pFadeLength then
  23.     put "fading in: " & pCurrentOpacity
  24.     pCurrentOpacity = float(pElapsedTime) / pFadeLength * 100.0
  25.     member("3d").camera("DefaultView").overlay[pOverlayNumber].blend = pCurrentOpacity
  26.     go(the frame)
  27.   else
  28.     if pElapsedTime < (pFadeLength + pPictureLength) then
  29.       put "showing picture"
  30.       member("3d").camera("DefaultView").overlay[pOverlayNumber].blend = 100
  31.       go(the frame)
  32.     else
  33.       if pElapsedTime < (pFadeLength + pPictureLength + pFadeLength) then
  34.         put "fading out"
  35.         fadeOutProgress = pElapsedTime - (pFadeLength + pPictureLength)
  36.         pCurrentOpacity = 100 - (float(fadeOutProgress) / pFadeLength * 100)
  37.         member("3d").camera("DefaultView").overlay[pOverlayNumber].blend = pCurrentOpacity
  38.         go(the frame)
  39.       else
  40.         put "removed"
  41.         member("3d").camera("DefaultView").overlay[pOverlayNumber].blend = 0
  42.         go(the frame + 1)
  43.       end if
  44.     end if
  45.   end if
  46. end
  47.  
  48. on endSprite me
  49.   theMember = member("3d")
  50.   theCamera = theMember.camera("DefaultView")
  51.   theCamera.removeOverlay(pOverlayNumber)
  52.   theMember.deleteTexture(pTextureName)
  53. end
  54.  
  55. on getPropertyDescriptionList
  56.   vPDList = [:]
  57.   setaProp(vPDList, #pFadeLength, [#comment: "Length of each fade (in seconds):", #format: #integer, #default: 2])
  58.   setaProp(vPDList, #pPictureLength, [#comment: "Length of time to show picture (in seconds):", #format: #integer, #default: 5])
  59.   txtrList = []
  60.   repeat with j = 1 to the number of castLibs
  61.     repeat with i = 1 to the number of castMembers of castLib j
  62.       if member(i, j).type = #bitmap then
  63.         txtrList.append(member(i, j))
  64.       end if
  65.     end repeat
  66.   end repeat
  67.   setaProp(vPDList, #pPicture, [#comment: "The picture to show:", #format: #member, #default: txtrList[1], #range: txtrList])
  68.   return vPDList
  69. end
  70.  
  71. on getBehaviorDescription me
  72.   return "Place this behavior in the score script channel to create " & RETURN & "a fade-in (of the specified length) to an overlay of the " & RETURN & "specified picture (for the specified length of time), followed " & RETURN & "by a fade-out (same length as fade-in).  At the end of the fade-" & RETURN & "out, the timeline playhead will progress to the next frame."
  73. end
  74.  
  75. on getBehaviorTooltip me
  76.   return "Create a fade-in, pause, then fade-out of a picture (like a slideshow)."
  77. end
  78.